home *** CD-ROM | disk | FTP | other *** search
/ PC Home 49 / PC_Home_Issue_49.iso / lldemo / lldemo.shr / ROSETTA.EXE / ROSETTA.DXR / 00605_path scripts.ls < prev    next >
Encoding:
Text File  |  1996-06-24  |  13.6 KB  |  397 lines

  1. global gHasPathIni
  2.  
  3. on setType
  4.   global gType, gSlash
  5.   if the machineType = 256 then
  6.     set gType to #PC
  7.     set gSlash to "\"
  8.   else
  9.     set gType to #MAC
  10.     set gSlash to ":"
  11.   end if
  12. end
  13.  
  14. on getCDInfo x
  15.   global gCDList
  16.   if gCDList = [] then
  17.     return "No Data Found,,Times,Plain"
  18.   end if
  19.   set theCD to getAt(gCDList, x)
  20.   set title to getaProp(theCD, #cdTitle)
  21.   set title2 to getaProp(theCD, #cdTitle2)
  22.   set cdFont to getaProp(theCD, #cdFont)
  23.   set style to getaProp(theCD, #cdFontStyle)
  24.   return title & "," & title2 & "," & cdFont & "," & style
  25. end
  26.  
  27. on fillFromOneVolume theVol, theID
  28.   global gChapters, gCDList, gType, gSlash
  29.   set ignoreThis to 0
  30.   set cdPathName to EMPTY
  31.   set testCD to FileIO(mnew, "read", theID)
  32.   if objectp(testCD) then
  33.     set cdinfo to testCD(mReadFile)
  34.     testCD(mdispose)
  35.     set cdType to 2
  36.     set cdTitle to item 2 of cdinfo
  37.     set cdTitle2 to item 3 of cdinfo
  38.     set sep to item 9 of cdinfo
  39.     if sep = EMPTY then
  40.       set sep to "-"
  41.     end if
  42.     if (item 10 of cdinfo = "yes") or (gType = #MAC) then
  43.       set onCD to 1
  44.     else
  45.       set onCD to 0
  46.     end if
  47.     set pctPath to item 11 of cdinfo
  48.     set runOnCD to item 12 of cdinfo
  49.     if cdTitle = "Russian" then
  50.       set cdFont to "Cyrillic"
  51.       set cdFontStyle to "Plain"
  52.       set cdTitle to "Heccrbq zpsr"
  53.       set cdTitle2 to "1"
  54.     else
  55.       set cdFont to "Times"
  56.       set cdFontStyle to "Bold"
  57.       if cdTitle = "Fran┬ìais" then
  58.         set cdTitle to "Fran├ºais"
  59.       else
  60.         if cdTitle = "EspaΓÇôol" then
  61.           set cdTitle to "Espa├▒ol"
  62.         end if
  63.       end if
  64.     end if
  65.   else
  66.     set pctPath to EMPTY
  67.     set runOnCD to EMPTY
  68.     set sep to "-"
  69.     set cdType to 1
  70.     set cdFont to "Times"
  71.     set cdFontStyle to "Bold"
  72.     set CDDescs to "DEMO,ESPA├æOL,ENGLISH,FRAN├çAIS,DEUTSCH"
  73.     set CDLanguageList to "Demo,Espa├▒ol,English,Fran├ºais,Deutsch"
  74.     if gType = #MAC then
  75.       set onCD to 1
  76.       set CDTitles to "The Rosetta Stone,RS Espa├▒ol Ia,RS English Ia,RS Fran├ºais Ia,RS Deutsch Ia"
  77.       set numTitles to the number of items in CDTitles
  78.       set ignoreThis to 1
  79.       repeat with j = 1 to numTitles
  80.         if theVol = item j of CDTitles then
  81.           set cdTitle to item j of CDDescs
  82.           set cdLanguage to item j of CDLanguageList
  83.           if cdTitle = "DEMO" then
  84.             set cdTitle2 to EMPTY
  85.           else
  86.             set cdTitle2 to "Level Ia"
  87.           end if
  88.           set ignoreThis to 0
  89.         end if
  90.       end repeat
  91.     else
  92.       set onCD to 0
  93.       set CDFiles to "\russian_\russian_.01-,\espa_ol_\espa_ol_.01-,\english_\english_.01-,\fran_ais\fran_ais._01,\deutsch_\deutsch_.01-"
  94.       set CDPathNameList to "demo,espa_ol_\,english_\,fran_ais\,deutsch_\"
  95.       set numTitles to the number of items in CDFiles
  96.       set ignoreThis to 1
  97.       repeat with j = 1 to numTitles
  98.         set testCD to FileIO(mnew, "read", theVol & item j of CDFiles)
  99.         if objectp(testCD) then
  100.           testCD(mdispose)
  101.           set cdTitle to item j of CDDescs
  102.           set cdLanguage to item j of CDLanguageList
  103.           if cdTitle = "DEMO" then
  104.             set cdTitle2 to EMPTY
  105.           else
  106.             set cdTitle2 to "Level Ia"
  107.           end if
  108.           set cdPathName to item j of CDPathNameList
  109.           set ignoreThis to 0
  110.           exit repeat
  111.         end if
  112.       end repeat
  113.     end if
  114.   end if
  115.   if ignoreThis = 0 then
  116.     add(gCDList, [#path: theVol & gSlash, #type: cdType, #Separator: sep, #TextonCD: onCD, #cdTitle: cdTitle, #cdTitle2: cdTitle2, #cdFont: cdFont, #cdFontStyle: cdFontStyle, #cdPathName: cdPathName, #pctPath: pctPath, #runOnCD: runOnCD])
  117.     set cdindex to count(gCDList)
  118.     if cdType = 1 then
  119.       if cdTitle = "DEMO" then
  120.         set chaps to "English 01-01,English 01-02,English 01-03,English 01-07,English 01-10,English 02-10,English 03-07,English 06-05,English 08-08,English 08-12,English 13-03,English 14-01,Deutsch 01-01,Deutsch 01-02,Deutsch 01-03,Deutsch 01-07,Deutsch 01-10,Deutsch 02-10,Deutsch 03-07,Deutsch 06-05,Deutsch 08-08,Deutsch 08-12,Deutsch 13-03,Deutsch 14-01,Fran├ºais 01-01,Fran├ºais 01-02,Fran├ºais 01-03,Fran├ºais 01-07,Fran├ºais 01-10,Fran├ºais 02-10,Fran├ºais 03-07,Fran├ºais 06-05,Fran├ºais 08-08,Fran├ºais 08-12,Fran├ºais 13-03,Fran├ºais 14-01,Espa├▒ol 01-01,Espa├▒ol 01-02,Espa├▒ol 01-03,Espa├▒ol 01-07,Espa├▒ol 01-10,Espa├▒ol 02-10,Espa├▒ol 03-07,Espa├▒ol 06-05,Espa├▒ol 08-08,Espa├▒ol 08-12,Espa├▒ol 13-03,Espa├▒ol 14-01,Russian 01-01,Russian 01-02,Russian 01-03,Russian 01-07,Russian 01-10,Russian 02-10,Russian 03-07,Russian 06-05,Russian 08-08,Russian 08-12,Russian 13-03,Russian 14-01"
  121.         repeat with i = 1 to the number of items in chaps
  122.           set aChap to [#chap: item i of chaps, #cd: cdindex]
  123.           add(gChapters, aChap)
  124.         end repeat
  125.       else
  126.         repeat with i = 1 to 8
  127.           repeat with j = 1 to 12
  128.             set aChap to [#chap: cdLanguage & " " & pad(i) & "-" & pad(j), #cd: cdindex]
  129.             if (i > 4) or (j < 12) then
  130.               add(gChapters, aChap)
  131.             end if
  132.           end repeat
  133.         end repeat
  134.       end if
  135.     else
  136.       if gType = #MAC then
  137.         set catname to "catmac.trs"
  138.       else
  139.         set catname to "catmpc.trs"
  140.       end if
  141.       set testCD to FileIO(mnew, "read", theVol & gSlash & catname)
  142.       if objectp(testCD) then
  143.         set chaps to testCD(mReadFile)
  144.         testCD(mdispose)
  145.         repeat with i = 1 to the number of lines in chaps
  146.           set c to line i of chaps
  147.           if the last word in c = "CD" then
  148.             set l to length(c)
  149.             delete char l - 2 to l of c
  150.           end if
  151.           if word 1 of c = "Fran┬ìais" then
  152.             set c to "Fran├ºais " & word 2 of c
  153.           else
  154.             if word 1 of c = "EspaΓÇôol" then
  155.               set c to "Espa├▒ol " & word 2 of c
  156.             end if
  157.           end if
  158.           if c <> EMPTY then
  159.             set aChap to [#chap: c, #cd: cdindex]
  160.             add(gChapters, aChap)
  161.           end if
  162.         end repeat
  163.       end if
  164.     end if
  165.   end if
  166. end
  167.  
  168. on findChapLocs
  169.   global gCDList, gChapters, gType, gAnnounceText, gXobj
  170.   set gCDList to []
  171.   set gChapters to []
  172.   if gType = #MAC then
  173.     set volumeList to getVolumes()
  174.   else
  175.     set volumeList to "c:,d:,e:,f:,g:,h:,i:,j:,k:,l:,m:,n:,o:,p:,q:,r:,s:,t:,u:,v:,w:,x:,y:,z:"
  176.     gXobj(mErrorMode, 1)
  177.   end if
  178.   set testCD to FileIO(mnew, "read", the pathName & "path.ini")
  179.   if objectp(testCD) then
  180.     set gHasPathIni to 1
  181.     set the itemDelimiter to "@"
  182.     set PathFile to testCD(mReadFile)
  183.     testCD(mdispose)
  184.     set alsoaPath to item 1 of PathFile
  185.     if gType = #PC then
  186.       if not (alsoaPath contains ":") then
  187.         set testCD to FileIO(mnew, "read", the pathName & "CHAPTERS\CHAPTERS.INI")
  188.         if objectp(testCD) then
  189.           set iniEntry to testCD(mReadFile)
  190.           testCD(mdispose)
  191.           set alsoaPath to char offset("=", iniEntry) + 1 of iniEntry & ":\" & alsoaPath
  192.         end if
  193.       end if
  194.     end if
  195.     delete item 1 of PathFile
  196.     set the itemDelimiter to numToChar(10)
  197.     set gAnnounceText to EMPTY
  198.     repeat with i = 1 to the number of items in PathFile
  199.       put item i of PathFile after gAnnounceText
  200.     end repeat
  201.     set the itemDelimiter to ","
  202.     set volumeList to alsoaPath & "," & volumeList
  203.   else
  204.     set gAnnounceText to EMPTY
  205.     set gHasPathIni to 0
  206.   end if
  207.   set numTitles to the number of items in volumeList
  208.   set j to 1
  209.   set dirListCD to EMPTY
  210.   repeat while j <= numTitles
  211.     set theTry to item j of volumeList
  212.     set isOurs to 1
  213.     if gType = #MAC then
  214.       set theID to theTry & ":" & "CDID.TRS"
  215.       set testCD to FileIO(mnew, "read", theTry & ":" & "The Rosetta Stone:Rosetta Prefs")
  216.       if not objectp(testCD) then
  217.         set testCD to FileIO(mnew, "read", theTry & ":" & "The Rosetta Stone Folder:Rosetta Prefs")
  218.         if not objectp(testCD) then
  219.           set testCD to FileIO(mnew, "read", theID)
  220.           if not objectp(testCD) then
  221.             set isOurs to 0
  222.           end if
  223.         end if
  224.       end if
  225.     else
  226.       set theID to theTry & "\" & "CDID.TRS"
  227.       set testCD to FileIO(mnew, "read", theTry & "\" & "license-.-re")
  228.       if not objectp(testCD) then
  229.         set testCD to FileIO(mnew, "read", theID)
  230.         if not objectp(testCD) then
  231.           set isOurs to 0
  232.         end if
  233.       end if
  234.     end if
  235.     if objectp(testCD) then
  236.       testCD(mdispose)
  237.     end if
  238.     if isOurs then
  239.       fillFromOneVolume(theTry, theID)
  240.     end if
  241.     set j to j + 1
  242.   end repeat
  243.   if (gType = #PC) and objectp(gXobj) then
  244.     gXobj(mErrorMode, 0)
  245.   end if
  246. end
  247.  
  248. on findChapPaths language, unit, chapter
  249.   global gChapters, gCDList, gType, gSlash
  250.   set pathList to [:]
  251.   set chapName to language & " " & pad(unit) & "-" & pad(chapter)
  252.   set n to count(gChapters)
  253.   repeat with i = 1 to n
  254.     set aChap to getAt(gChapters, i)
  255.     if getaProp(aChap, #chap) = chapName then
  256.       set cd to getaProp(aChap, #cd)
  257.       set theCD to getAt(gCDList, cd)
  258.       set basePath to getaProp(theCD, #path)
  259.       set chapType to getaProp(theCD, #type)
  260.       set textPlace to getaProp(theCD, #TextonCD)
  261.       set sep to getaProp(theCD, #Separator)
  262.       set word2 to word 2 of chapName
  263.       set title to getaProp(theCD, #cdTitle)
  264.       set pctPath to getaProp(theCD, #pctPath)
  265.       if pctPath = EMPTY then
  266.         set pctPath to char 1 to 3 of chapName
  267.       end if
  268.       if chapType = 2 then
  269.         set chapPath to basePath & char 1 to 3 of chapName & char 1 to 2 of word2 & sep & char 4 to 5 of word2 & gSlash
  270.         set chapPctPath to basePath & pctPath & char 1 to 2 of word2 & sep & char 4 to 5 of word2 & gSlash
  271.       else
  272.         if gType = #MAC then
  273.           set chapPath to basePath & chapName & gSlash
  274.         else
  275.           set chapPath to basePath & char 1 to 8 of chapName & gSlash
  276.         end if
  277.         set chapPctPath to chapPath
  278.       end if
  279.       if textPlace = 1 then
  280.         set textPath to chapPath
  281.       else
  282.         set textPath to the pathName & "text\" & char 1 to 3 of title & "text\"
  283.       end if
  284.       if chapType = 1 then
  285.         set index to unit & "-" & pad(chapter)
  286.         if gType = #MAC then
  287.           setaProp(pathList, #textPath, textPath & chapName)
  288.           setaProp(pathList, #pictpath, chapPath & index & " Pictures:" & index & "-")
  289.           setaProp(pathList, #pictsuffix, EMPTY)
  290.           setaProp(pathList, #sndpath, chapPath & index & " Sounds:" & index & "-")
  291.           setaProp(pathList, #sndsuffix, EMPTY)
  292.         else
  293.           set oldBase to getaProp(theCD, #cdPathName)
  294.           if oldBase = "demo" then
  295.             if language = "Espa├▒ol" then
  296.               set oldBase to "espa_ol_\"
  297.             else
  298.               if language = "English" then
  299.                 set oldBase to "english_\"
  300.               else
  301.                 if language = "Fran├ºais" then
  302.                   set oldBase to "fran_ais\"
  303.                 else
  304.                   if language = "Deutsch" then
  305.                     set oldBase to "deutsch_\"
  306.                   else
  307.                     if language = "Russian" then
  308.                       set oldBase to "russian_\"
  309.                     end if
  310.                   end if
  311.                 end if
  312.               end if
  313.             end if
  314.           end if
  315.           setaProp(pathList, #textPath, textPath & char 1 to 3 of chapName & pad(unit) & "_" & pad(chapter))
  316.           setaProp(pathList, #pictpath, basePath & oldBase & index & "_Pic\" & index & "-")
  317.           setaProp(pathList, #pictsuffix, EMPTY)
  318.           setaProp(pathList, #sndpath, basePath & oldBase & index & "_Sou\" & index & "-")
  319.           setaProp(pathList, #sndsuffix, EMPTY)
  320.         end if
  321.       else
  322.         set prefix to char 1 to 2 of chapName
  323.         set index to pad(unit) & pad(chapter)
  324.         if textPlace = 1 then
  325.           if gType = #MAC then
  326.             setaProp(pathList, #textPath, textPath & prefix & index & ".TXT")
  327.           else
  328.             setaProp(pathList, #textPath, textPath & prefix & index & ".TXT")
  329.           end if
  330.         else
  331.           setaProp(pathList, #textPath, textPath & char 1 to 3 of chapName & char 1 to 2 of index & "_" & char 3 to 4 of index)
  332.         end if
  333.         setaProp(pathList, #pictpath, chapPctPath & char 1 to 2 of pctPath & index & "P" & gSlash & char 1 to 2 of pctPath & index)
  334.         setaProp(pathList, #pictsuffix, ".PCT")
  335.         setaProp(pathList, #sndpath, chapPath & prefix & index & "S" & gSlash & prefix & index)
  336.         setaProp(pathList, #sndsuffix, ".SND")
  337.       end if
  338.       setaProp(pathList, #type, chapType)
  339.       return pathList
  340.     end if
  341.   end repeat
  342.   return [:]
  343. end
  344.  
  345. on makeImagePath pathList, which, index
  346.   global gPatchSnd
  347.   if which = #PICT then
  348.     set basePath to getaProp(pathList, #pictpath)
  349.     set suffix to getaProp(pathList, #pictsuffix)
  350.   else
  351.     if (gPatchSnd = 1) and (index = 28) then
  352.       set index to 37
  353.     end if
  354.     if (gPatchSnd = 1) and (index = 39) then
  355.       set index to 25
  356.     end if
  357.     set basePath to getaProp(pathList, #sndpath)
  358.     set suffix to getaProp(pathList, #sndsuffix)
  359.   end if
  360.   return basePath & pad(index) & suffix
  361. end
  362.  
  363. on isRunningOnCD
  364.   global gCDList
  365.   if gHasPathIni = 1 then
  366.     return 0
  367.   end if
  368.   set n to count(gCDList)
  369.   repeat with i = 1 to n
  370.     set aCD to getAt(gCDList, i)
  371.     if getaProp(aCD, #runOnCD) <> "runOnCD" then
  372.       set basePath to getaProp(aCD, #path)
  373.       if (basePath & "The Rosetta Stone:") = the pathName then
  374.         return 1
  375.       end if
  376.       if (basePath & "The Rosetta Stone Folder:") = the pathName then
  377.         return 1
  378.       end if
  379.     end if
  380.   end repeat
  381.   return 0
  382. end
  383.  
  384. on getAllChaps
  385.   global gChapters
  386.   set n to count(gChapters)
  387.   set ret to EMPTY
  388.   repeat with i = 1 to n
  389.     set aChap to getAt(gChapters, i)
  390.     set chap to getaProp(aChap, #chap)
  391.     put chap & RETURN after ret
  392.   end repeat
  393.   set l to the number of chars in ret
  394.   delete char l of ret
  395.   return ret
  396. end
  397.